package com.carltechnology.mahjonggamecaculation.dao.impl;

import android.content.ContentValues;

import com.carltechnology.mahjonggamecaculation.dao.IMahjongDataDao;
import com.carltechnology.mahjonggamecaculation.dao.IMahjongGameInsertComponent;
import com.carltechnology.mahjonggamecaculation.mode.IDetailGameData;
import com.carltechnology.mahjonggamecaculation.mode.IGameData;
import com.carltechnology.mahjonggamecaculation.mode.IGameRuntimeData;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by WZTCM on 2016/6/28.
 */
public class MahjongGameInsertDataComponent implements IMahjongGameInsertComponent {
    private IMahjongDataDao mDao;
    public MahjongGameInsertDataComponent(IMahjongDataDao dao) {
        this.mDao = dao;
    }
    @Override
    public void insertMahjongGameData(IGameData mode){
        mDao.insertData
                (String.valueOf(MahjongGameSqliteHelper.DATABASE_INFO.TABLE_GAMEDATA_NAME),
                        mode.getContentValues());


    }
    @Override
    public void insertMahjongDetailGameData(IDetailGameData mode){
        mDao.insertData
                (String.valueOf(MahjongGameSqliteHelper.DATABASE_INFO.TABLE_DETAILDATA_NAME),
                        mode.getContentValues());

    }
    @Override
    public void insertRuntimeGameData(IGameRuntimeData mode){
        mDao.insertData
                (String.valueOf(MahjongGameSqliteHelper.DATABASE_INFO.TABLE_RUNTIME_NAME),
                        mode.getContentValues());
    }

    @Override
    public void insertRunningModeList(List<IGameRuntimeData> list) {
        List<ContentValues> contentValues = new ArrayList<>();
        for (IGameRuntimeData tmp:list){
            contentValues.add(tmp.getContentValues());
        }
        mDao.insertListDatas
                (String.valueOf(MahjongGameSqliteHelper.DATABASE_INFO.TABLE_RUNTIME_NAME),
                        contentValues);
    }


}
